package com.taotao.conf;

import com.taotao.slink.service.DayVisitService;
import com.taotao.slink.service.VisitStatistics;
import com.taotao.slink.utils.localstore.LocalStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 *  用于异步统计访问量
 * </p>
 *
 * @author fanbeibei
 * @version 1.0.0
 * @date 2023/6/27 11:19
 */
@Configuration
public class VisitStatisticsConfig {

    @Value("${taotao.local-store.base-path}")
    private String basePath;
    @Value("${taotao.local-store.module}")
    private String module;
    @Autowired
    private DayVisitService dayVisitService;

    @Bean
    public LocalStore localStore(){
        return new LocalStore(basePath,module);
    }

    @Bean(initMethod = "init",destroyMethod = "shutdown")
    public VisitStatistics visitStatistics(){
        return new VisitStatistics(localStore(),dayVisitService);
    }
}
